﻿using HK.Core.Common.Protocol;
using HK.Core.Common.Protocol.Data;
using HK.Core.Pool.Protocol;

namespace HK.Core.Logs.Protocol
{
    /// <summary>
    /// Log日志等级定义
    /// <para>* 级别越高，日志输出越少。</para>
    /// <para>* 输出的日志只输出大于等于当前日志级别的日志。</para>
    /// </summary>
    public enum LogLevel 
    {
        
        /// <summary>
        /// 全部输出(A).
        /// </summary>
        All = 0,
        /// <summary>
        /// Debug(T).
        /// </summary>
        Debug = 1,
        Test = Debug,
        /// <summary>
        /// 信息:运行(RI).
        /// </summary>
        RInfo = 2,
        /// <summary>
        /// 信息:逻辑(LI).
        /// </summary>
        LInfo = 3,
        /// <summary>
        /// 警告(W).
        /// </summary>
        Warning = 4,
        /// <summary>
        /// 错误(E).
        /// </summary>
        Error = 5,
        /// <summary>
        /// 致命日志(F).
        /// </summary>
        Fatal = 6,
        /// <summary>
        /// 全关闭.
        /// </summary>
        Off = 7,
        /// <summary>
        /// 未知
        /// </summary>
        UnKnow = 99999
    }
    
    /// <summary>
    /// 接口 : 日志设定
    /// </summary>
    public interface ILogSettings : IJsonData
    {
        /// <summary>
        /// 日志等级
        /// </summary>
        LogLevel Level { get; }
        
        /// <summary>
        /// 日志输出标志位
        /// <para>* 输出到日志文件</para>
        /// </summary>
        bool OutPut { get; }

        /// <summary>
        /// 日志文件大小(单位:MB)
        /// </summary>
        float FileSize { get; }

        /// <summary>
        /// 日志线程输出
        /// </summary>
        bool Thread { get; }
    }
    
    /// <summary>
    /// 接口 : 日志数据
    /// </summary>
    public interface ILogData : IPoolElement
    {
        /// <summary>
        /// 日志No
        /// </summary>
        long No { get; }
        
        /// <summary>
        /// 日志等级
        /// </summary>
        LogLevel Level { get; }
        
        /// <summary>
        /// 日志内容
        /// </summary>
        string Log { get; }
        
        /// <summary>
        /// Build标志位
        /// </summary>
        bool IsBuild { get; }

        /// <summary>
        /// 重置Log信息
        /// </summary>
        /// <param name="iNo">日志No</param>
        /// <param name="iLevel">日志等级</param>
        /// <param name="iLog">日志</param>
        /// <param name="iIsBuild">打包日志标志位</param>
        void Reset(long iNo, LogLevel iLevel, string iLog, bool iIsBuild = false);
    }
}
